<?php
include("auth.php"); 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel=stylesheet type="text/css" href="../css/main.css">
<link rel="shortcut icon" href="../img/favicon.ico" type="image/x-icon" />
<script src="../js/jquery-1.8.0.min.js" type="text/javascript"></script>
<script src="../js/admin_pray.js" type="text/javascript"></script>

<title>澳門華人基督會</title>
</head>
<body>

<?php 
include("../Top.php");
include("menu.php");   
?>

<table cellpadding="0" cellspacing="0" width="1000" background="../img/context_background.gif" align="center">
<tr>
        <td align="center">
        <table cellpadding="0" cellspacing="0" width="900">
          <tr valign="top">
            <td align="left">
            <img src="../img/pray_title.jpg" border="0" />
            </td>
          </tr>
        </table>
        </td>
      </tr>
	  <tr>
	  	<td align="center">
        <table cellpadding="0" cellspacing="0" width="900" class="admincontenttable">
<?php 
require_once("../class/PrayList.php");
$praylist = new PrayList(20); 
if (isset($_REQUEST['page'])){
	$page = $_REQUEST['page'];
}else{
	$page = 1;
}

$result = $praylist->getPray($page, '<>', 'closed');

foreach($result as $row){  
  echo "<tr valign='top'>
                 <td width='30'' align='left'>
                 &nbsp;<img src='../img/header.gif' border='0' />
                 </td>";
  echo "<td width='120' align='left'>";
  echo date('Y-m-d', strtotime($row['updated_date'])) . ''; 
  echo "</td><td align='left'>";
  echo "<span class='span_subject'>" . $row['subject'] . "</span>"; 
  echo "<div class='div_message'><pre>" . $row['message'] . "</pre></div>"; 
  echo "</td>";
  echo "</td><td width='150' align='left'>祈禱者: <span class='span_prayer'>" . $row['prayer'] . "</span></td>";
  echo "<td></td>";
  echo "<td width='30'><form name='approve_form' action='approve_message.php' method='POST'>";
  echo "<input type='hidden' class='hid_id' value='" . $row['pid'] . "' readonly='readonly'/>";
  echo "<input type='hidden' name='pid' value='" . $row['pid'] . "' readonly='readonly'/>";
  echo "<input type='hidden' name='status' value='" . $row['status'] . "' readonly='readonly'/>";
  echo "<input type='hidden' name='page' value='" . $page . "' readonly='readonly'/>";
  if ($row['status'] == "true")
    echo "<input type='image' src='../img/approve.png' alt='approve'>";
  else
    echo "<input type='image' src='../img/unapprove.png' alt='unapprove'>";
  echo "</form></td>";
  echo "<td width='30'>";
  echo "<input type='hidden' class='hid_id' value='" . $row['pid'] . "' readonly='readonly'/>";
  echo "<img src='../img/edit.gif' alt='edit_image' class='img_edit'/>";
  echo "</td>";
  echo "<td width='30'><form name='del_form' action='del_message.php' class='form_del_form' method='POST'>";
  echo "<input type='hidden' name='pid' value='" . $row['pid'] . "' readonly='readonly'/>";
  echo "<input type='hidden' name='type' value='pray' readonly='readonly'/>";
  echo "<input type='hidden' name='page' value='" . $page . "' readonly='readonly'/>";
  echo "<input type='image' id='input_del' src='../img/del.gif' alt='Submit button'>";
  echo "</form></td></tr>";
} 
  
?>
      <tr valign="middle">
	    <td height="50" align="left" colspan="5">
<?php
	for($i=1; $i<=$praylist->getPage('<>', 'closed'); $i++){
		echo "<a class='infPage' href='pray_admin.php?page=" . $i . "'>" . $i . "</a>";
	}
?>
            </td>
			<td align="right" colspan="2">Add: </td>
            <td align="left"><img id="img_new" src="../img/new.png"/></td>
          </tr>
		  
			</table>
		</td>
	  </tr>
	  <tr>
	  	<td align="center">
		<form name="form1" method="post" action="add_message.php" >
        <table cellpadding="0" cellspacing="0" width="900px" class="div_let_pray">
		    <tr>
				<td colspan="5" align="left">
					<span id="span_status_label">New message: </span>
				</td>
			</tr>
			<tr>
				<td align="left" width="70px" height="30">
					<span id="span_message_label">主題: </span>
				</td>
				<td align="left" >
					<input type="text" name="subject" id="txt_subject" style="width:500px;" />
				</td>
				<td align="left" width="80px">
					<span id="span_prayer_label" >祈禱者: </span>
				</td>
				<td align="left" >
					<input type="text" name="prayer" id="txt_prayer" style="width:150px;" />
					<input type="hidden" name="status" value="true"/>
				</td>
				<th width="100px"></th>
			</tr>
			<tr>
			    <td align="left" valign="top">
					<span id="span_context_label">內容: </span>
				</td>
				<td colspan="3" align="left">
				    <input type='hidden' name='pid' id="hid_id" value=''/>
				    <input type='hidden' name='page' value='<?php echo $page;  ?>' readonly='readonly'/>
					<textarea name="message" id="txt_message" rows="4" style="width:100%;height:100px;"></textarea>
				</td>
				<td align="center" valign="bottom">
					<input type="image" src="../img/confirm.gif" id="but_submit" name="add" value="Save"/>
					<input type="hidden" name="type" value="pray" readonly="readonly"/>
				</td>
			</tr>
			<tr>
				<td align="left" colspan="5" height="5">
				<?php 
				if(isset($_REQUEST['return_message']))
				{
					echo $_REQUEST['return_message'];
				} 
	   ?>
				</td>
			</tr>
		</table>
		
		</form>
		<br />
		</td>
	  </tr>
</table>

<?php 	
include("../Footer.php"); 
?>

</body>
</html>